<?php namespace Manage\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

use Manage\Agent;
use Session;

abstract class Controller extends BaseController {

	use DispatchesCommands, ValidatesRequests;


    public $data;
    public $err = false;

    public function __construct()
    {
    	//todo
    	if( ! Session::has('nickname') )
    	{
    		$this->err = true;
            
            if( \Route::getFacadeRoot()->current()->uri() !== 'login' )         
            
            echo '<script>window.location.href="'.url('login').'"</script>';
            // return;
    	}

        $this->data = array(

        		'user' => Session::get('user'),
                'nickname' => Session::get('nickname'),
                'id' => Session::get('id'),
                'province' => Session::get('province'),
                'city' => Session::get('city'),
                'is_created' => Session::get('is_created')
        );

    }
}
